<!doctype html>

<!--
  ~ License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
  -->

<html>

<head>
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Demo of Firefly Tools</title>
</head>

<body>

<div id="fireflyLostConnWarn" data-decor="medium" class="warning-div right"></div>


<div style="width: 500px; padding: 50px 0 0 20px;">
    <h3>Firefly - new API demo</h3>
    <a href="javascript:loadMoving()">load Images</a>
</div>

<div>
    <div id="image1_div" style="display: inline-block; width: 550px; height: 550px; margin: 10px;"></div>
    <div id="image2_div" style="display: inline-block; width: 550px; height: 550px; margin: 10px;"></div>
</div>


<script type="text/javascript">
    {

        function onFireflyLoaded() {

            firefly.setGlobalImageDef({
                ZoomType: 'TO_WIDTH',
                ColorTable: 0 // 数字对应 颜色列表下面的颜色列表 参考文档fits-plotting-parameters.md
            });

            firefly.action.dispatchWcsMatch({ 
              matchType: 'Pixel',  
              lockMatch: true  
            });

            firefly.debug = true;

            const req1 = {
                plotId: 'image1',
                URL: 'http://10.34.1.111:3030/vt_images/L1X/Imaging/2025-04-29/GP-PPT-4983/SVT_GP-PPT_04983_R_04604_250429T000129_22054.fit',
                Title: 'SVT_GP-PPT_04983_R_04604_250429T000129_22054.fit'
            };
            const req11 = {
                plotId: 'image1',
                file: '/data/fits_images/nfsroot-vxpp/L1X/Imaging/2025-05-01/ToO-NOM-GRB-5073/SVT_ToO-NOM-GRB_05073_R_04637_250501T051931_23371.fit',
                Title: 'SVT_GP-PPT_04983_R_04604_250429T000129_22054.fit'
            };

            firefly.showImage('image1_div', req11);
            const req2 = {
                plotId: 'image2',
                URL: 'http://10.34.1.111:3030/vt_images/L1X/Imaging/2025-04-29/GP-PPT-4983/SVT_GP-PPT_04983_B_04604_250429T000129_22054.fit',
                Title: '2025-04-29/GP-PPT-4983/SVT_GP-PPT_04983_B_04604_250429T000129_22054.fit'
            };
            const req21 = {
                plotId: 'image2',
                file: '/data/fits_images/nfsroot-vxpp/L1X/Imaging/2025-04-29/GP-PPT-4983/SVT_GP-PPT_04983_B_04604_250429T000129_22054.fit',
                Title: '2025-04-29/GP-PPT-4983/SVT_GP-PPT_04983_B_04604_250429T000129_22054.fit'
            };
            firefly.showImage('image2_div', req21);


            const regionAry = [  
                'image; box 250 250 100 80 0 # color=red',  
                'image; box 250 250 50 40 0 # color=red'  
            ];  
            firefly.action.dispatchCreateRegionLayer(
                'region112',   // 区域层ID  
                'Region Layer 1',  // 区域层标题  
                null, // 无文件路径  
                regionAry,  // 区域数组  
                ['image2'] // 要显示区域的图像ID  
            );
        }
        function loadMoving() {
            var m49025b_143_2= {
                file: '/data/fits_images/nfsroot-vxpp/L1X/Imaging/2025-05-01/ToO-NOM-GRB-5073/SVT_ToO-NOM-GRB_05073_R_04637_250501T051931_23371.fit',
                plotId: 'm49025b_143_2',
                OverlayPosition : '330.347003;-2.774482;EQ_J2000',
                ZoomType : 'TO_WIDTH_HEIGHT',
                Title: 'SVT_ToO-NOM-GRB_05073_R_04637_250501T051931_23371',
                plotGroupId : 'movingGroup',
            };
            var m49273b_134_2= {
                file: '/data/fits_images/nfsroot-vxpp/L1X/Imaging/2025-05-01/ToO-NOM-GRB-5073/SVT_ToO-NOM-GRB_05073_B_04637_250501T051931_23371.fit',
                plotId: 'm49273b_134_2',
                OverlayPosition : '333.539702;-0.779310;EQ_J2000',
                ZoomType : 'TO_WIDTH_HEIGHT',
                Title: 'SVT_ToO-NOM-GRB_05073_B_04637_250501T051931_23371',
                plotGroupId : 'movingGroup',
            };
            var m49277b_135_1= {
                file: '/data/fits_images/nfsroot-vxpp/L1X/Imaging/2025-04-29/GP-PPT-4983/SVT_GP-PPT_04983_R_04604_250429T000129_22054.fit',
                plotId: 'm49277b_135_1',
                OverlayPosition : '333.589054;-0.747251;EQ_J2000',
                ZoomType : 'TO_WIDTH_HEIGHT',
                Title: 'SVT_GP-PPT_04983_R_04604_250429T000129_22054',
                plotGroupId : 'movingGroup',
            };
            var m49289b_134_2= {
                file: '/data/fits_images/nfsroot-vxpp/L1X/Imaging/2025-04-29/GP-PPT-4983/SVT_GP-PPT_04983_B_04604_250429T000129_22054.fit',
                plotId: 'm49289b_134_2',
                OverlayPosition : '333.736578;-0.651222;EQ_J2000',
                ZoomType : 'TO_WIDTH_HEIGHT',
                Title: 'SVT_GP-PPT_04983_B_04604_250429T000129_22054',
                plotGroupId : 'movingGroup',
            };

            firefly.getViewer().showImage( m49025b_143_2);
            firefly.getViewer().showImage( m49273b_134_2);
            firefly.getViewer().showImage( m49277b_135_1);
            firefly.getViewer().showImage( m49289b_134_2);
            // firefly.action.dispatchWcsMatch({ 
            //   matchType: 'Pixel',  
            //   lockMatch: true,
            //   plotId: ['m49025b_143_2','m49273b_134_2','m49277b_135_1','m49289b_134_2'] 
            // });
            const regionAry = [  
                'image; box 250 250 100 80 0 # color=red',  
                'image; box 250 250 50 40 0 # color=red'  
            ];  
            // firefly.action.dispatchCreateRegionLayer(
            //     'region1',   // 区域层ID  
            //     'Region Layer 1',  // 区域层标题  
            //     null, // 无文件路径  
            //     regionAry,  // 区域数组  
            //     ['m49025b_143_2'] // 要显示区域的图像ID  
            // );
            // layerId = "region1";
            // selectMode = {selectStyle: 'UprightBox', selectColor: '#DAA520', lineWidth: 1}
            // firefly.action.dispatchCreateRegionLayer(layerId, layerId, null, regionAry, 'm49289b_134_2', selectMode);
            // firefly.action.dispatchCreateRegionLayer(layerId, layerId, null, regionAry, null, selectMode, dispatcher = window.ffViewer.dispatch);
            // firefly.action.dispatchCreateRegionLayer(layerId, layerId, null, regionAry, 'regiontest', selectMode);
            // firefly.action.dispatchCreateRegionLayer(layerId, layerId, null, regionAry, null, selectMode, dispatcher = window.ffViewer.dispatch);
        }
    }
</script>


<script src="http://10.34.1.111:5066/firefly/firefly_loader.js"></script>

</body>
</html>